import 'package:flutter/material.dart';
import '../config/color_config.dart';

class CustomSearchBar extends StatelessWidget {
  final TextEditingController controller;
  final Function(String) onChanged;
  final String hintText;

  const CustomSearchBar({
    Key? key,
    required this.controller,
    required this.onChanged,
    this.hintText = '搜索...',
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
      child: TextField(
        controller: controller,
        onChanged: onChanged,
        decoration: InputDecoration(
          hintText: hintText,
          hintStyle: TextStyle(color: ColorConfig.searchHintColor),
          prefixIcon: Icon(Icons.search, color: ColorConfig.searchIconColor),
          border: OutlineInputBorder(
            borderRadius: BorderRadius.circular(30.0),
            borderSide: BorderSide(color: ColorConfig.inputBorder),
          ),
          enabledBorder: OutlineInputBorder(
            borderRadius: BorderRadius.circular(30.0),
            borderSide: BorderSide(color: ColorConfig.inputBorder),
          ),
          focusedBorder: OutlineInputBorder(
            borderRadius: BorderRadius.circular(30.0),
            borderSide: BorderSide(color: ColorConfig.primary),
          ),
          contentPadding:
              const EdgeInsets.symmetric(horizontal: 20.0, vertical: 12.0),
          filled: true,
          fillColor: ColorConfig.searchBackground,
        ),
      ),
    );
  }
}
